home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / RESOURCE.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  5KB  |  209 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.3  $
  6. //
  7. // Defines classes handling Windows resources
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_RESOURCE_H)
  10. # define OWL_RESOURCE_H
  11.  
  12. #if !defined(OWL_DEFS_H)
  13. # include <owl/defs.h>
  14. #endif
  15. #if !defined(OWL_GDIBASE_H)
  16. # include <owl/gdibase.h>
  17. #endif
  18. #if !defined(SERVICES_WSYSINC_H)
  19. # include <services/wsysinc.h>
  20. #endif
  21. #if !defined(WINSYS_WSYSCLS_H)
  22. # include <winsys/wsyscls.h>
  23. #endif
  24.  
  25. #if defined(BI_NAMESPACE)
  26. namespace OWL {
  27. #endif
  28.  
  29. //
  30. // Predefined resource types
  31. //
  32. #if !defined(RT_TOOLBAR) && defined(BI_PLAT_WIN32)
  33. # define RT_TOOLBAR  MAKEINTRESOURCE(241)
  34. #endif
  35. #if !defined(RT_NEWDIALOG) && defined(BI_PLAT_WIN32)
  36. # define RT_NEWDIALOG MAKEINTRESOURCE(0x2000|0x0005)
  37. #endif
  38.  
  39. // Generic definitions/compiler options (eg. alignment) preceeding the 
  40. // definition of classes
  41. #include <services/preclass.h>
  42.  
  43. // Forward ref.
  44. //
  45. class _OWLCLASS TBitmap;
  46. class _OWLCLASS TGadgetWindow;
  47.  
  48. //
  49. // The DLGTEMPLATE structure, documented in the Windows Programmer's
  50. // is defined only in the 32-bit system headers.
  51. //
  52. #if defined(BI_PLAT_WIN16)
  53. # if !defined(DLGTEMPLATE_DEFINED)
  54.     struct  DLGTEMPLATE {  
  55.       DWORD   style;
  56.       BYTE    cdit;
  57.       int     x;
  58.       int     y;
  59.       int     cx;
  60.       int     cy;
  61.       // char MenuName[];
  62.       // char ClassName[];
  63.       // char CaptionText[];
  64.     };
  65. #   define DLGTEMPLATE_DEFINED
  66. # endif  
  67. #endif    
  68.  
  69. //
  70. //
  71. //
  72. #if defined(BI_PLAT_WIN32)
  73. # if !defined(DLGTEMPLATEEX_DEFINED)
  74.     struct  DLGTEMPLATEEX {
  75.       ushort  version;
  76.       ushort  signature;
  77.       uint32  helpId;
  78.       uint32  exStyle;
  79.       uint32  style;
  80.       ushort  itemCount;
  81.       short   x;
  82.       short   y;
  83.       short   cx;
  84.       short   cy;
  85.       // wchar_t MenuName[];          // Name or ordinal
  86.       // wchar_t ClassName[];         // Name or ordinal
  87.       // wchar_t CaptionText[];
  88.     };
  89. #   define  DLGTEMPLATEEX_DEFINED
  90. # endif  
  91. #endif
  92.  
  93. //
  94. // Structure describing the binary layout of toolbar resources
  95. // NOTE: Toolbar resource is only available in 32-bit
  96. //
  97. #if defined(BI_PLAT_WIN32)
  98. # if !defined(TOOLBARTEMPLATE_DEFINED)
  99.     struct TOOLBARTEMPLATE {
  100.       ushort    version;          // Resource version
  101.       ushort    width;            // Width of each bitmap glyph
  102.       ushort    height;           // Height of each bitmap glyph
  103.       ushort    count;            // Number of glyphs
  104.       ushort    ids[1];           // Array of ids of glyphs+separators
  105.     };
  106. #   define TOOLBARTEMPLATE_DEFINED    
  107. # endif
  108. #endif
  109.  
  110.  
  111. //
  112. // class TToolbarRes
  113. // ~~~~~ ~~~~~~~~~~~
  114. //
  115. #if defined(BI_PLAT_WIN32)
  116. class _OWLCLASS TToolbarRes : public TResource<TOOLBARTEMPLATE, RT_TOOLBAR> {
  117.   public:
  118.     TToolbarRes(HINSTANCE hInst, TResId id, TAutoDelete = AutoDelete);
  119.    ~TToolbarRes();
  120.  
  121.     TBitmap&    GetBitmap();
  122.     int         GetCount() const;
  123.     ushort*     GetIds() const;
  124.     int         GetWidth() const;
  125.     int         GetHeight() const;
  126.  
  127.   protected:
  128.     TBitmap*    ToolbarBitmap;
  129.     bool        ShouldDelete;
  130.     TOOLBARTEMPLATE& TBInfo() const;
  131. };
  132.  
  133. //
  134. // class TToolbarBldr
  135. // ~~~~~ ~~~~~~~~~~~~
  136. class _OWLCLASS TToolbarBldr {
  137.   public:
  138.     TToolbarBldr(TGadgetWindow& win, TResId id, HINSTANCE hinst = 0);
  139.    ~TToolbarBldr();
  140.     void            Build();
  141.  
  142.   protected:
  143.     TGadgetWindow&  Win;
  144.     TToolbarRes*    TbarRes;
  145.     TResId          Id;
  146.     HINSTANCE       Hinst;
  147. };
  148. #endif  //  BI_PLAT_WIN32
  149.  
  150. //
  151. // class TDialogRes
  152. // ~~~~~ ~~~~~~~~~~
  153. //
  154. class _OWLCLASS TDialogRes {
  155.   public:
  156.     TDialogRes(HINSTANCE hInstance, TResId id);
  157. #if defined(BI_PLAT_WIN32)
  158.     TDialogRes(HINSTANCE hInstance, TResId id, LANGID langid);
  159. #endif
  160.    ~TDialogRes();
  161.  
  162.     // Validate resource was found, loaded & locked
  163.     //
  164.     bool            IsOK() const;
  165.     
  166.     // Retrieve information about the underlying binary template
  167.     //
  168. #if defined(BI_PLAT_WIN32)
  169.     bool            IsDialogEx() const;
  170.     DLGTEMPLATEEX*  GetTemplateEx() const;
  171. #endif
  172.     DLGTEMPLATE*    GetTemplate() const;
  173.  
  174.     // Querry about info. stored in template
  175.     //
  176.     void      GetRect(TRect& rect) const;
  177.  
  178.     //
  179.     // Enumeration of various strings stored with a dialog resource
  180.     //
  181.     enum TDlgResText {
  182.       drtMenuName,              // String of menu resource used by dialog
  183.       drtClassName,             // Class name of dialog
  184.       drtCaption                // Caption of dialog
  185.     };
  186.  
  187.     //
  188.     // Retrieve a particular string from the resource
  189.     //
  190.     int       GetText(char far* buffer, int size, 
  191.                       TDlgResText which = drtCaption) const;
  192.  
  193.   protected:
  194.     TResource<DLGTEMPLATE, RT_DIALOG>*      OldResource;
  195. #if defined(BI_PLAT_WIN32)
  196.     TResource<DLGTEMPLATEEX, RT_NEWDIALOG>* NewResource;
  197. #endif
  198. };
  199.  
  200. // Generic definitions/compiler options (eg. alignment) following the 
  201. // definition of classes
  202. #include <services/posclass.h>
  203.  
  204. #if defined(BI_NAMESPACE)
  205. } // namespace OWL
  206. #endif
  207.  
  208. #endif  //  OWL_RESOURCE_H
  209.